package cz.hanis.android.pubaccounting.model;

import java.util.ArrayList;
import java.util.List;

public class Pub extends ModelBase {

	private String name;
	private double longitude;
	private double latitude;
	private String address;
	private String hompage;
	
	private List<Item> items;
	
	public Pub() {		
		this.items = new ArrayList<Item>();
		this.address = "";
		this.hompage = "";
	}

	public Pub(String name) {
		this();
		this.name = name;
	}
	
	
	@Override
	public String toString() {
		return "Pub [name=" + name + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pub other = (Pub) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public List<Item> getItems() {
		return items;
	}
	
	public void addItem(Item item) {
		items.add(item);
	}

	public String getHompage() {
		return hompage;
	}

	public void setHompage(String hompage) {
		this.hompage = hompage;
	}
	
	public boolean isLocalizable() {
		return latitude != 0.0 && longitude != 0.0;
	}
	
}
